﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libs.Content;

public partial class Controls_Right_Cate : System.Web.UI.UserControl
{
    public int CateID
    {
        get;
        set;
    }

    public int RowNumber
    {
        get;
        set;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        NewsCategories _Cate = new NewsCategories() { CateID = CateID };
        _Cate = _Cate.Get();
        hlCate.NavigateUrl = NewsUtils.CateLink(_Cate.CateID.ToString(), _Cate.Url, "0");
        hlCate.Text = _Cate.Name.ToUpper();

        NewsWeb _NewsWeb = new NewsWeb();
        rptList.DataSource = _NewsWeb.GetList(CateID, 0, RowNumber);
        rptList.DataBind();

        if (rptList.Items.Count == 0)
        {
            panelCate.Visible = false;
        }
    }

    protected string GetHtml(string _Title, string _Lead, string _Url, string _ImageUrl, DateTime _PublishedTime)
    {
        string s;
        if (_ImageUrl.Length > 0)
        {
            s = Resources.Html.EntertainmentImg;
            s = s.Replace("$ImageUrl$", AppUtils.ImageUrl(_ImageUrl, "66", "48"));
        }
        else
        {
            s = Resources.Html.Entertainment;
        }
        s = s.Replace("$Link$", _Url);
        s = s.Replace("$Title$", _Title);
        return s;
    }
}